package com.example.intentopen;

import java.lang.reflect.Field;
import java.util.List;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;

public class TestC extends AndroidTestCase{
	
	public void testA() throws Exception{
		PackageManager pm = getContext().getPackageManager();
		List<PackageInfo> pminfos = pm.getInstalledPackages(0);
		for(PackageInfo p:pminfos){
//			System.out.println(p.packageName);
			ApplicationInfo info = p.applicationInfo;
//			System.out.println(pm.getApplicationLabel(info).toString());
			if (p.packageName.equals(p.applicationInfo.packageName)) {
				if((p.applicationInfo.flags&ApplicationInfo.FLAG_SYSTEM)>0){
					System.out.println(p.packageName);
				}
			}
//			PackageStats ps = new PackageStats(p.packageName);
//			File fileAPK = new File(info.sourceDir);
//			System.out.println(fileAPK.length());
//			System.out.println(info.sourceDir);
			Context mmscontxt = getContext().createPackageContext("com.android.settings",
					Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY
					);
			Class<?> maClass = Class.forName("com.android.settings.ManageApplications",
					true, mmscontxt.getClassLoader());
			Object maobj = maClass.newInstance();
			Field f_mPm = maClass.getDeclaredField("mPm");
			f_mPm.setAccessible(true);
		}
		
		
	}
}
